package serviceloader;

import java.util.ServiceLoader;

/**
 * Created by lxue on 16/5/7.
 */
public class Main {
    public static void main(String[] args) {
        ServiceLoader<IHello> serviceLoader = ServiceLoader.load(IHello.class);
        serviceLoader.forEach(service -> service.sayHello());
        //为何没有输出
        for (IHello hello : serviceLoader) {
            System.out.println(hello.sayHello());
        }
    }
}
